from __future__ import absolute_import
import yaml

class RepoConfig(object):
    def __init__(self):
        pass
    
    def get_name(self):
        return self._config.get('name', True)
        
    def load_file(self, f):
        self._config = yaml.load(open(f).read())
        
    def get_enabled(self):
        return self._config.get('enabled', True)
        
    def get_priority(self):
        return self._config.get('priority', 99)
    
    def get_url(self):
        if 'metalink' in self._config:
            return ('metalink', self._config.get('metalink'))
        elif 'mirrorlist' in self._config:
            return ('mirrorlist', self._config.get('mirrorlist'))
        elif 'url' in self._config:
            return ('url', self._config.get('url'))
        
    def get_repo_type(self):
        return 'rpm-md'
        
    def get_expires_seconds(self):
        return self._config.get('metadata_expire', 900)
